package com.glsc.ngateway.common.base.domain.mysql.opmanagemain.ledger;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author liwei
 * 台账模板
 */
@Data
@Entity
@Table(name = "t_ledger_template")
@org.hibernate.annotations.Table(appliesTo = "t_ledger_template", comment = "台账模板")
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class LedgerTemplate implements Serializable {
    private static final long serialVersionUID = -3466162886857873912L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", columnDefinition = "int(20) comment '台账模板id'")
    private Integer id;

    @ApiModelProperty(value = "台账模板名称")
    @Column(name = "name", columnDefinition = "varchar(255) COMMENT '台账模板名称'")
    private String name;

//    @ApiModelProperty(value = "台账模板类型  数据字典:t_ledger_type")
//    @Column(name = "type", columnDefinition = "varchar(20) COMMENT '台账模板类型'")
//    private String type;

    @ApiModelProperty(value = "备注")
    @Column(name = "memo", columnDefinition = "varchar(255) COMMENT '备注'")
    private String memo;

    @Column(name = "user_id", columnDefinition = "int DEFAULT NULL COMMENT '创建人id'")
    @ApiModelProperty(value = "创建人id")
    private Long userId;

    @ApiModelProperty(value = "创建时间 yyyy-MM-dd HH:mm:ss")
    @Column(name = "create_time", columnDefinition = "datetime comment '创建时间'", updatable = false)
    @org.hibernate.annotations.CreationTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime createTime;

    @Column(name = "to_task_type", columnDefinition = "varchar(40) COMMENT '待办任务类型,数据字典t_opmanage_task_type'")
    @ApiModelProperty(value = "待办任务类型")
    private String toTaskType;


    //任务列表
    @Transient
    List<LedgerTaskTemplate> taskTemplateList;


}
